/**
 * Alibaba.com.cn Inc.
 * Copyright (c) 2004-2021 All Rights Reserved.
 */
package com.starlink.utils;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;

import java.util.Date;

/**
 * @author zhanghong
 * @version BizCodeUtil.java, v 0.1 2023/7/18 16:39 下午 BizCodeUtil Exp $$
 */
public class BizCodeUtil {

    /**
     * 解析任务编码信息
     * @param taskCode
     * @return
     */
    public static Pair<Date, Long> parseTaskCodeInfo(String taskCode) {
        if (StringUtils.isEmpty(taskCode)) {
            return null;
        }
        taskCode = taskCode.replace("LS", "");

        String dateStr = taskCode.substring(0, 6);
        String numStr = taskCode.substring(6);

        DateTime fileDate = DateUtil.parse(dateStr, "yyMMdd");
        Long fileNum = Long.parseLong(numStr);
        return Pair.of(fileDate, fileNum);
    }
}
